<template>
	<view>
		<template v-if="lat && lng">
			<punch-clock ref="clockChild" :lat="lat" :lng="lng"></punch-clock>
		</template>
		<tab-bar v-if="tipNumber || tipNumber == 0" :tipNumber="tipNumber"></tab-bar>
	</view>
</template>

<script>
import punchClock from '@/components/punchclock/punchClock.vue'
import { BASE_IMG_URL } from '@/api/http.js'
import tabBar from '@/components/tabbar/tabbar'
import { netBriefingData, netAchievedata, netIndexRankingdata, netJurisdiction, netFinanceData, netAfterData, netAfterAchieve } from '@/api/api.js'
import { netMesList, netGetUserInfo } from '@/api/user.js'
import { makeDate } from '@/utils/util.js'
import { mapState } from 'vuex'

export default {
	components: {
		tabBar,
		punchClock,
	},
	data() {
		return {
			BASE_IMG_URL: BASE_IMG_URL,
			tipNumber: null,
			//当前登录者的 身份
			identity: 'sales',   //sales 销售部， finance 财务部，  after 售后部， else 其他
			permission: {},  //权限
			lng: '',
			lat: '',
		}
	},
	onLoad() {
	},
	onShow() {
		this.getPunch()
		//提示消息
		this.getTipNumber()
		this.getJurisdiction()

	},
	methods: {
		//数据权限
		getJurisdiction() {
				netJurisdiction().then(res=>{
					uni.setStorageSync('permission',res.data)
					this.permission = res.data
					// this.$store.commit('SETPERMISSION',res.data)
				})
			},
		getPunch() {
			uni.getLocation({
				type: 'gcj02',
				isHighAccuracy: true,
				altitude: true,
				success: (data) => {
					console.log(data, '经纬度')
					this.lng = data.longitude
					this.lat = data.latitude
				},
				fail: (err) => {
					console.log(err, '====')
					uni.showToast({
						title: '次数频繁，请稍后再试',
						icon: 'none'
					})
				}
			})
		},
		//消息 提示
		getTipNumber() {
			netMesList().then(res => {
				this.tipNumber = res.data.total
				netGetUserInfo().then(ress => {
					this.userInfo = ress.data
					uni.setStorageSync('userinfo', ress.data)
					uni.setStorageSync('roleType', res.data.role_type)
				})
			})
		},
	}
}
</script>


<style>
page {
	background: #F4F4F4;
}
</style>
<style lang="scss" scoped>
.pre-right {
	display: flex;
	justify-content: flex-end;
	align-items: center;
	padding: 0 30rpx;
	margin: 20rpx 0 30rpx 0;

	.form_right {
		min-width: 180rpx;
		height: 50rpx;
		line-height: 48rpx;
		border-radius: 8rpx;
		background: #fff;
		margin-right: 15rpx;
		font-size: 22rpx;
		color: #666;
		text-align: center;
		display: flex;
		justify-content: center;
		align-items: center;
		box-shadow: 2rpx 2rpx 50rpx rgba(0, 0, 0, 0.1);

		.bottomimg {
			width: 30rpx;
			height: 33rpx;
		}
	}
}

// 常用功能
.newbox {
	width: 690rpx;
	padding: 25rpx 24rpx 0;
	margin: 0 30rpx 30rpx;
	border: 1px solid #EDEDED;
	box-shadow: 0px 0px 16rpx 2rpx rgba(220, 220, 220, 0.3);
	border-radius: 20rpx;
	background: #fff;

	.new_title {
		font-size: 26rpx;
		font-weight: bold;
		color: #333;
		margin-bottom: 25rpx;
	}

	.newtabbox {
		display: flex;
		justify-content: flex-start;
		flex-wrap: wrap;

		.lxr_tab {
			text-align: center;
			margin-right: 33rpx;
			margin-bottom: 45rpx;
			width: 100rpx;

			&:nth-child(5n) {
				margin-right: 0;
			}

			.tabimg {
				width: 80rpx;
				height: 80rpx;
			}

			.tabtext {
				margin-top: 8rpx;
				font-size: 24rpx;
				color: #333333;
			}
		}
	}
}

.title {
	margin-left: 52rpx;
	display: flex;
	align-items: center;
	font-size: 26rpx;
	color: #666;

	&::before {
		margin-left: 20rpx;
		content: '';
		position: absolute;
		left: 30rpx;
		width: 16rpx;
		height: 30rpx;
		border-radius: 8rpx;
		background: $uni-text-color;
	}
}

.l_search {
	padding: 10rpx 50rpx 20rpx;
	background: #cfe8fe;
	display: flex;
	justify-content: space-between;
	align-items: center;

	.l_selfsearch {
		width: 580rpx;
		height: 68rpx;
		border-radius: 34rpx;
		background: #FFFFFF;
		display: flex;
		justify-content: flex-start;
		align-items: center;
		padding: 0 24rpx;

		.searimg {
			width: 48rpx;
			height: 47rpx;
			margin-right: 24rpx;
		}

		.lself {
			font-size: 26rpx;
			color: rgba(2, 135, 255, 0.5);
		}
	}

	.l_tip {
		width: 48rpx;
		height: 50rpx;
		position: relative;

		.new_tip {
			position: absolute;
			right: -9rpx;
			top: -20rpx;
			border-radius: 50%;
			background: #F13E27;
			color: #fff;
			font-size: 26rpx;
			width: 40rpx;
			height: 40rpx;
			text-align: center;
			line-height: 40rpx;
			z-index: 2;
		}

		.tipimg {
			width: 48rpx;
			height: 50rpx;
		}
	}

	.l_saoma {
		width: 40rpx;
		height: 40rpx;

		.saomaimg {
			width: 40rpx;
			height: 40rpx;
		}
	}
}

.lxr_tab_warp {
	padding: 0 50rpx;
	background: linear-gradient(180deg, #cfe8fe 0%, #F1F4F6 48%, #F4F4F4 100%);
	display: flex;
	justify-content: flex-start;
	align-items: center;
	flex-wrap: wrap;

	.lxr_tab {
		text-align: center;
		margin-right: 83rpx;
		margin-bottom: 35rpx;
		width: 100rpx;

		&:nth-child(4n) {
			margin-right: 0;
		}

		.tabimg {
			width: 80rpx;
			height: 80rpx;
		}

		.tabtext {
			font-size: 24rpx;
			color: #333333;
		}
	}
}

.lxr_title {
	border-bottom: 1rpx solid #EDEDED;

	.title_warp {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 15rpx 20rpx 20rpx 0;

		.title_name {
			display: flex;
			justify-content: flex-start;
			align-items: center;
			font-size: 30rpx;
			color: #333333;
			font-weight: bold;

			.cirimg {
				width: 11rpx;
				height: 33rpx;
				margin-right: 15rpx;
			}
		}

		.title_right {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			font-size: 24rpx;
			color: #4E80F5;

			.sche_more {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: $uni-text-color;

				.sanimg {
					width: 18rpx;
					height: 26rpx;
					margin-left: 10rpx;
				}
			}

			.sche_add {
				margin-right: 20rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				font-size: 24rpx;
				color: $uni-text-color;

				.addimg {
					width: 38rpx;
					height: 38rpx;
					margin-right: 10rpx;
				}
			}
		}
	}
}

.wk_tab_warp {
	padding: 20rpx 0;
	display: flex;
	justify-content: space-around;
	align-items: center;

	.wk_tab {
		.tab_num {
			font-size: 28rpx;
			color: #999;
		}

		.tab_text {
			font-size: 24rpx;
			color: #999;
			margin-bottom: 20rpx;
		}
	}

	.wk_tabactive {
		.tab_num {
			text-align: left;
			color: #333;
		}

		.tab_text {
			color: #333;
			margin-bottom: 12rpx;
		}

		.tab_ac {
			width: 70rpx;
			height: 8rpx;
			background: $uni-btn-bg-color;
			border-radius: 4rpx;
			margin: 0 auto;
		}
	}
}

.warp_list {
	padding: 24rpx;
}

.jianbao-zy {
	padding: 25rpx 0 50rpx 0;
	margin: 0 30rpx 30rpx;
	border: 1px solid #EDEDED;
	box-shadow: 0px 0px 16rpx 2rpx rgba(220, 220, 220, 0.3);
	border-radius: 20rpx;
	background: #fff;
}

//数据简报
.brie_li_box {
	border-top: 1rpx solid #ededed;
	border-bottom: 1rpx solid #ededed;
	padding: 15rpx 24rpx;

	.pre_content {
		background-color: #fff;
		display: flex;
		flex-wrap: wrap;

		.content_item {
			width: 33.33%;
			text-align: center;

			:first-child {
				font-size: 32rpx;
				font-weight: 600;
				margin-top: 26rpx;
				margin-bottom: 10rpx;
				color: #333;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			:last-child {
				font-size: 24rpx;
				padding: 0 20rpx;
				color: #999;
			}
		}
	}
}

.brie_box {
	.brie_conbox {
		display: flex;
		justify-content: space-evenly;
		align-items: center;
	}

	.brie_box_item {
		padding: 10rpx 8rpx 24rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		background: #f8f8f8;
		flex-shrink: 0;
		width: 190rpx;

		.brie_top {
			margin-bottom: 15rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			.brie_data,
			.brie_title {
				font-size: 28rpx;
				color: #666;
			}
		}

		.brie_bot {
			display: flex;
			flex-direction: column;
			align-items: center;

			.left_number {
				font-size: 24rpx;
				color: #666;
				white-space: normal;
				word-break: break-all;
				margin-bottom: 8rpx;
			}
		}
	}
}

// 排行榜
.paihang-zy {
	padding: 25rpx 0 50rpx 0;
	margin: 0 30rpx 30rpx;
	border: 1px solid #EDEDED;
	box-shadow: 0px 0px 16rpx 2rpx rgba(220, 220, 220, 0.3);
	border-radius: 20rpx;
	background: #fff;
}

.rankingbox {
	width: 690rpx;
	background: #fff;
	margin: 24rpx auto;
	padding: 0 30rpx 30rpx;
	border-radius: 20rpx;

	.rank_tab_box {
		display: flex;
		justify-content: space-around;
		align-items: center;
		margin-bottom: 20rpx;
		border-top: 1rpx solid #EDEDED;
		border-bottom: 1rpx solid #EDEDED;

		.rank_tab {
			font-size: 30rpx;
			padding: 0 32rpx;
			margin: 24rpx 0;
			border-right: 1rpx solid #EDEDED;

			&:last-child {
				border-right: 0;
			}
		}
	}
}

.rank_list {
	.rank_li {
		width: 620rpx;
		margin: 0 auto 24rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 15rpx 35rpx;
		border-radius: 20rpx;
		background: rgba(153, 153, 153, 0.2);

		.rank_li_left {
			display: flex;
			justify-content: flex-start;
			align-items: center;

			.rank_num {
				font-size: 24rpx;
				color: #666666;
				margin-right: 10rpx;
				width: 40rpx;
				height: 40rpx;
				text-align: center;
				line-height: 38rpx;
			}

			.saleimg {
				width: 60rpx;
				height: 60rpx;
				border-radius: 50%;
				margin-right: 10rpx;
			}

			.salename {
				font-size: 30rpx;
				color: #333333;
			}
		}

		.rank_li_right {
			font-size: 30rpx;
			color: #666666;
		}
	}

	.rank_li_fir {
		background: rgba(255, 155, 38, 0.2);

		.rank_li_left {
			.rank_num {
				color: rgba(255, 155, 38, 1);
				border: 1rpx solid rgba(255, 155, 38, 1);
				border-radius: 50%;
			}

			.salename {
				color: rgba(51, 51, 51, 1);
			}
		}

		.rank_li_right {
			color: rgba(255, 155, 38, 1);
		}
	}

	.rank_li_sec {
		background: rgba(0, 202, 141, 0.2);

		.rank_li_left {
			.rank_num {
				color: rgba(0, 202, 141, 1);
				border: 1rpx solid rgba(0, 202, 141, 1);
				border-radius: 50%;
			}

			.salename {
				color: rgba(51, 51, 51, 1);
			}
		}

		.rank_li_right {
			color: rgba(0, 202, 141, 1);
		}
	}

	.rank_li_thr {
		background: rgba(78, 128, 245, 0.2);

		.rank_li_left {
			.rank_num {
				color: rgba(78, 128, 245, 1);
				border: 1rpx solid rgba(78, 128, 245, 1);
				border-radius: 50%;
			}

			.salename {
				color: rgba(78, 128, 245, 1)
			}
		}

		.rank_li_right {
			color: rgba(78, 128, 245, 1);
		}
	}
}
</style>
